<template>
    <van-search v-model="searchval" placeholder="请输入搜索关键词" />
    <div v-for="item in searchApiData">
        <router-link :to="{name:'detail',params:{goods_id:item.goods_id}}">
            <van-card :price="item.goods_price" :title="item.goods_name"
            :thumb="item.goods_small_logo ? item.goods_small_logo : 'https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg'" />
        </router-link>
    </div>
</template>

<script setup>
import { searchApi } from '@/api/api';
import _ from 'lodash';
import { ref, watch } from 'vue';
let searchApiData = ref([])
let searchval=ref('')
watch(searchval,_.debounce(val=>{
    searchApi(val).then(res=>{
        searchApiData.value=res.data.message.goods
    })
},3000))
</script>

<style lang="scss" scoped></style>